#!/bin/sh
#
# Copyright (C) 2000-2022 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# Run a simple backup of the Bacula build directory with TLS
#   communications code enabled then restore it.
#
TestName="tls-test"
JobName=tls
. scripts/functions

scripts/cleanup
scripts/copy-tls-confs
echo "${cwd}/build" >${cwd}/tmp/file-list

change_jobname CompressedTest $JobName
start_test

# useful for testing Fix org#2714, define "me" in you /etc/hosts file as an alias of your localhost
# $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Address", "me", "Client", localhost-fd)'
# $bperl -e 'add_attribute("$conf/bacula-dir.conf", "TLS Allowed CN", "localhost", "Client", localhost-fd)'
      
cat <<END_OF_DATA >tmp/bconcmds
messages
@$out tmp/log1.out
status all
status all
messages
label storage=File volume=TestVolume001 pool=Default
run job=$JobName storage=File yes
wait
messages
@# 
@# now do a restore
@#
@$out tmp/log2.out
restore where=${cwd}/tmp/bacula-restores select storage=File
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA

run_bacula
check_for_zombie_jobs storage=File
stop_bacula

check_two_logs
check_restore_diff
end_test
